package com.bytedance.speech.speechdemo

import android.R
import android.app.ListActivity
import android.os.Bundle
import android.view.View
import android.widget.ArrayAdapter
import android.widget.ListView
import com.bytedance.speech.speechengine.SpeechEngineGenerator

/**
 *
 */
class ListDemoActivity : ListActivity() {


    enum class Action(val actionName: String,val call:(activity:ListDemoActivity)->Unit) {

        HEBEI("火山引擎",{
            it.startActivity(android.content.Intent(it, MainActivity::class.java))
        }),
        JIANGSHU("demo",{
            it.startActivity(android.content.Intent(it, HttpActivity::class.java))
        });



    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        //1.数据源

        val data = arrayListOf<String>()
        Action.values().forEach { data.add(it.actionName) }

        //2.适配器
        val arrayAdapter: ArrayAdapter<*> =
            ArrayAdapter<String>(this, R.layout.simple_list_item_1, data)
        //3.绑定
        listAdapter = arrayAdapter

    }

    override fun onListItemClick(l: ListView, v: View, position: Int, id: Long) {
        super.onListItemClick(l, v, position, id)
        Action.values()[position].call.invoke(this)
    }
}